package mytest;

import java.util.HashMap;

import jp.ds.comgrove.dao.DbManager;
import admage.common.form.ArgForm;
import admage.common.log.Logger;
import admage.common.util.AppUtil;

public class TestDbManager {
	public DbManager systemDb;
	public DbManager summaryDb;
	public ArgForm form = null;
	public Logger logger = null;

	public TestDbManager() {
		HashMap confMap = null;
		form = new ArgForm();

		confMap = AppUtil.Config.getConfigMap();
		logger = getLogger(confMap);
		form.setConfMap(confMap);

		String db_user = form.getConf(AppUtil.Config.DB_USER);
		String db_password = form.getConf(AppUtil.Config.DB_PASSWORD);

		systemDb = new DbManager(logger);
		summaryDb = new DbManager(logger);

		try {
			systemDb.connectSystem(confMap);
			summaryDb.connect(form.getConf(AppUtil.Config.SUM_DB_SERVER),
					form.getConf(AppUtil.Config.SUM_DB_SCHEMA), db_user,
					db_password);

		} catch (OutOfMemoryError e) {
			logger.writeMemoryErrorLog();

		} catch (Exception e) {
			logger.writeErrorLog(e);

		}
	}

	protected Logger getLogger(HashMap confMap){
		return new Logger("", "", confMap);
	}

}
